<%@page contentType="text/html; charset=UTF-8"%>
<%@taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@include file="/common/definition.jsp"%>

<html:html>
<style>
.tab-content {
	padding-top: 15px;
}
</style>
<tiles:insert beanName="admin-definition" flush="true">
	<tiles:put name="title"> Administrator Management </tiles:put>
	<tiles:put name="body" type="string">
		<div class="col-md-12 mainHome">
			<div class="col-md-12 text-center h2 borderBot">Quản lý User</div>
			<ul class="nav nav-tabs" style="padding-top: 5px;">
				<li class="active"><a href="#All" data-toggle="tab">All</a></li>
				<li><a href="#Moderator" data-toggle="tab">Moderator</a></li>
				<li><a href="#User" data-toggle="tab">User</a></li>
				<li><a href="#Shop" data-toggle="tab">Shop</a></li>
				<li><a href="#Banned" data-toggle="tab">Banned</a></li>
			</ul>
			<div class="tab-content"
				style="padding-bottom: 9px; border-bottom: 1px solid #ddd;">
				<div class="tab-pane fade in active" id="All">
					<table id="AllProfile"
						class="table table-striped table-hover table-condensed table-bordered m-melanin-datatable">
						<thead>
							<tr>
								<th width="70px">User ID</th>
								<th width="100px">UserName</th>
								<th width="225px">Email</th>
								<th width="142px">Quyền Hạn</th>
								<th width="89px">Tình Trạng</th>
								<th width="132px">Action</th>
							</tr>
						</thead>
						<tbody>
							<s:iterator value="profileModel.listprofileinfo"
								status="listinfoStatus" id="list">
								<tr>
									<td><s:property value="userID" /></td>
									<td><s:if test="role == 1">
											<s:property value="account" />
										</s:if> <s:else>
											<s:a action="editProfile-page">
												<s:property value="account" />
												<s:param name="userID" value="userID" />
											</s:a>
										</s:else>
									</td>
									<td><s:property value="email" /></td>

									<td><s:if test="role == 1">admin</s:if> <s:elseif
											test="role == 2">Product Manager</s:elseif> <s:elseif
											test="role == 3">User Manager</s:elseif> <s:elseif
											test="role == 4">User</s:elseif> <s:elseif test="role == 5">Shop</s:elseif>
									</td>
									<td><s:if test="isBanned == 0">Active</s:if> <s:elseif
											test="isBanned == 1">Banned</s:elseif>
									</td>

									<td><s:if test="role != 1">
											<s:if test="isBanned == 0">
												<s:a action="updateRole">Khóa Tài Khoản<s:param
														name="userID" value="userID" />
												</s:a>
											</s:if>
											<s:elseif test="isBanned == 1">
												<s:a action="updateRole">Mở Tài Khoản<s:param
														name="userID" value="userID" />
												</s:a>
											</s:elseif>
										</s:if></td>
								</tr>
							</s:iterator>
						</tbody>
					</table>
				</div>
				<div class="tab-pane fade" id="User">
					<table id="ModProfile"
						class="table table-striped table-hover table-condensed table-bordered">
						<thead>
							<tr>
								<th width="70px">User ID</th>
								<th width="100px">UserName</th>
								<th width="225px">Email</th>
								<th width="142px">Quyền Hạn</th>
								<th width="89px">Tình Trạng</th>
								<th width="132px">Action</th>
							</tr>
						</thead>
						<tbody>
							<s:iterator value="profileModel.listprofileinfo"
								status="listinfoStatus" id="list">
								<s:if test="role == 4">
									<tr>
										<td><s:property value="userID" /></td>
										<td><s:if test="role == 1">
												<s:property value="account" />
											</s:if> <s:else>
												<s:a action="editProfile">
													<s:property value="account" />
													<s:param name="userID" value="userID" />
												</s:a>
											</s:else>
										</td>
										<td><s:property value="email" /></td>

										<td><s:if test="role == 1">admin</s:if> <s:elseif
												test="role == 2">Product Manager</s:elseif> <s:elseif
												test="role == 3">User Manager</s:elseif> <s:elseif
												test="role == 4">User</s:elseif> <s:elseif test="role == 5">Shop</s:elseif>
										</td>
										<td><s:if test="isBanned == 0">Active</s:if> <s:elseif
												test="isBanned == 1">Banned</s:elseif>
										</td>

										<td><s:if test="role != 1">
												<s:if test="isBanned == 0">
													<s:a action="updateRole">Khóa Tài Khoản<s:param
															name="userID" value="userID" />
													</s:a>
												</s:if>
												<s:elseif test="isBanned == 1">
													<s:a action="updateRole">Mở Tài Khoản<s:param
															name="userID" value="userID" />
													</s:a>
												</s:elseif>
											</s:if></td>
									</tr>
								</s:if>
							</s:iterator>
						</tbody>
					</table>
				</div>
				<div class="tab-pane fade" id="Moderator">
					<table id="UserProfile"
						class="table table-striped table-hover table-condensed table-bordered">
						<thead>
							<tr>
								<th width="70px">User ID</th>
								<th width="100px">UserName</th>
								<th width="225px">Email</th>
								<th width="142px">Quyền Hạn</th>
								<th width="89px">Tình Trạng</th>
								<th width="132px">Action</th>
							</tr>
						</thead>
						<tbody>
							<s:iterator value="profileModel.listprofileinfo"
								status="listinfoStatus" id="list">
								<s:if test="role == 1 || role == 2 || role == 3">
									<tr>
										<td><s:property value="userID" /></td>
										<td><s:if test="role == 1">
												<s:property value="account" />
											</s:if> <s:else>
												<s:a action="editProfile">
													<s:property value="account" />
													<s:param name="userID" value="userID" />
												</s:a>
											</s:else>
										</td>
										<td><s:property value="email" /></td>

										<td><s:if test="role == 1">admin</s:if> <s:elseif
												test="role == 2">Product Manager</s:elseif> <s:elseif
												test="role == 3">User Manager</s:elseif> <s:elseif
												test="role == 4">User</s:elseif> <s:elseif test="role == 5">Shop</s:elseif>
										</td>
										<td><s:if test="isBanned == 0">Active</s:if> <s:elseif
												test="isBanned == 1">Banned</s:elseif>
										</td>

										<td><s:if test="role != 1">
												<s:if test="isBanned == 0">
													<s:a action="updateRole">Khóa Tài Khoản<s:param
															name="userID" value="userID" />
													</s:a>
												</s:if>
												<s:elseif test="isBanned == 1">
													<s:a action="updateRole">Mở Tài Khoản<s:param
															name="userID" value="userID" />
													</s:a>
												</s:elseif>
											</s:if></td>
									</tr>
								</s:if>
							</s:iterator>
						</tbody>
					</table>
				</div>
				<div class="tab-pane fade" id="Shop">
					<table id="ShopProfile"
						class="table table-striped table-hover table-condensed table-bordered">
						<thead>
							<tr>
								<th width="70px">User ID</th>
								<th width="100px">UserName</th>
								<th width="225px">Email</th>
								<th width="142px">Quyền Hạn</th>
								<th width="89px">Tình Trạng</th>
								<th width="132px">Action</th>
							</tr>
						</thead>
						<tbody>
							<s:iterator value="profileModel.listprofileinfo"
								status="listinfoStatus" id="list">
								<s:if test="role == 5">
									<tr>
										<td><s:property value="userID" /></td>
										<td><s:if test="role == 1">
												<s:property value="account" />
											</s:if> <s:else>
												<s:a action="editProfile">
													<s:property value="account" />
													<s:param name="userID" value="userID" />
												</s:a>
											</s:else>
										</td>
										<td><s:property value="email" /></td>

										<td><s:if test="role == 1">admin</s:if> <s:elseif
												test="role == 2">Product Manager</s:elseif> <s:elseif
												test="role == 3">User Manager</s:elseif> <s:elseif
												test="role == 4">User</s:elseif> <s:elseif test="role == 5">Shop</s:elseif>
										</td>
										<td><s:if test="isBanned == 0">Active</s:if> <s:elseif
												test="isBanned == 1">Banned</s:elseif>
										</td>

										<td><s:if test="role != 1">
												<s:if test="isBanned == 0">
													<s:a action="updateRole">Khóa Tài Khoản<s:param
															name="userID" value="userID" />
													</s:a>
												</s:if>
												<s:elseif test="isBanned == 1">
													<s:a action="updateRole">Mở Tài Khoản<s:param
															name="userID" value="userID" />
													</s:a>
												</s:elseif>
											</s:if></td>
									</tr>
								</s:if>
							</s:iterator>
						</tbody>
					</table>
				</div>
				<div class="tab-pane fade" id="Banned">
					<table id="BannedProfile"
						class="table table-striped table-hover table-condensed table-bordered">
						<thead>
							<tr>
								<th width="70px">User ID</th>
								<th width="100px">UserName</th>
								<th width="225px">Email</th>
								<th width="142px">Quyền Hạn</th>
								<th width="89px">Tình Trạng</th>
								<th width="132px">Action</th>
							</tr>
						</thead>
						<tbody>
							<s:iterator value="profileModel.listprofileinfo"
								status="listinfoStatus" id="list">
								<s:if test="isBanned == 1">
									<tr>
										<td><s:property value="userID" /></td>
										<td><s:if test="role == 1">
												<s:property value="account" />
											</s:if> <s:else>
												<s:a action="editProfile">
													<s:property value="account" />
													<s:param name="userID" value="userID" />
												</s:a>
											</s:else>
										</td>
										<td><s:property value="email" /></td>

										<td><s:if test="role == 1">admin</s:if> <s:elseif
												test="role == 2">Product Manager</s:elseif> <s:elseif
												test="role == 3">User Manager</s:elseif> <s:elseif
												test="role == 4">User</s:elseif> <s:elseif test="role == 5">Shop</s:elseif>
										</td>
										<td><s:if test="isBanned == 0">Active</s:if> <s:elseif
												test="isBanned == 1">Banned</s:elseif>
										</td>

										<td><s:if test="role != 1">
												<s:if test="isBanned == 0">
													<s:a action="updateRole">Khóa Tài Khoản<s:param
															name="userID" value="userID" />
													</s:a>
												</s:if>
												<s:elseif test="isBanned == 1">
													<s:a action="updateRole">Mở Tài Khoản<s:param
															name="userID" value="userID" />
													</s:a>
												</s:elseif>
											</s:if></td>
									</tr>
								</s:if>
							</s:iterator>
						</tbody>
					</table>
				</div>
			</div>
		</div>
		<script type="text/javascript">
			$(document)
					.ready(
							function() {
								$('#AllProfile')
										.dataTable(
												{
													"sPaginationType" : "bs_four_button",
													"oLanguage" : {
														"sSearch" : "",
														"sZeroRecords" : "Không có dữ liệu",
														"sEmptyTable" : "Không có dữ liệu",
														"sInfo" : "Hiển thị từ _START_ đến _END_. Tổng cộng: _TOTAL_ dòng.",
														"sInfoFiltered" : "",
														"sLengthMenu" : "Hiển thị _MENU_ Dòng",
														"sInfoEmpty" : 'Không tìm thấy dữ liệu.'
													},
												});
								$('#AllProfile')
										.each(
												function() {
													var datatable = $(this);
													// SEARCH - Add the placeholder for Search and Turn this into in-line form control
													var search_input = datatable
															.closest(
																	'.dataTables_wrapper')
															.find(
																	'div[id$=_filter] input');
													search_input.attr(
															'placeholder',
															'Tìm Kiếm');
													search_input
															.addClass('form-control input-sm');
													// LENGTH - Inline-Form control
													var length_sel = datatable
															.closest(
																	'.dataTables_wrapper')
															.find(
																	'div[id$=_length] select');
													length_sel
															.addClass('form-control input-sm');
												});
							});
			$(document)
					.ready(
							function() {
								$('#ModProfile')
										.dataTable(
												{
													"sPaginationType" : "bs_four_button",
													"oLanguage" : {
														"sSearch" : "",
														"sZeroRecords" : "Không có dữ liệu",
														"sEmptyTable" : "Không có dữ liệu",
														"sInfo" : "Hiển thị từ _START_ đến _END_. Tổng cộng: _TOTAL_ dòng.",
														"sInfoFiltered" : "",
														"sLengthMenu" : "Hiển thị _MENU_ Dòng",
														"sInfoEmpty" : 'Không tìm thấy dữ liệu.'
													},
												});
								$('#ModProfile')
										.each(
												function() {
													var datatable = $(this);
													// SEARCH - Add the placeholder for Search and Turn this into in-line form control
													var search_input = datatable
															.closest(
																	'.dataTables_wrapper')
															.find(
																	'div[id$=_filter] input');
													search_input.attr(
															'placeholder',
															'Tìm Kiếm');
													search_input
															.addClass('form-control input-sm');
													// LENGTH - Inline-Form control
													var length_sel = datatable
															.closest(
																	'.dataTables_wrapper')
															.find(
																	'div[id$=_length] select');
													length_sel
															.addClass('form-control input-sm');
												});
							});
			$(document)
					.ready(
							function() {
								$('#UserProfile')
										.dataTable(
												{
													"sPaginationType" : "bs_four_button",
													"oLanguage" : {
														"sSearch" : "",
														"sZeroRecords" : "Không có dữ liệu",
														"sEmptyTable" : "Không có dữ liệu",
														"sInfo" : "Hiển thị từ _START_ đến _END_. Tổng cộng: _TOTAL_ dòng.",
														"sInfoFiltered" : "",
														"sLengthMenu" : "Hiển thị _MENU_ Dòng",
														"sInfoEmpty" : 'Không tìm thấy dữ liệu.'
													},
												});
								$('#UserProfile')
										.each(
												function() {
													var datatable = $(this);
													// SEARCH - Add the placeholder for Search and Turn this into in-line form control
													var search_input = datatable
															.closest(
																	'.dataTables_wrapper')
															.find(
																	'div[id$=_filter] input');
													search_input.attr(
															'placeholder',
															'Tìm Kiếm');
													search_input
															.addClass('form-control input-sm');
													// LENGTH - Inline-Form control
													var length_sel = datatable
															.closest(
																	'.dataTables_wrapper')
															.find(
																	'div[id$=_length] select');
													length_sel
															.addClass('form-control input-sm');
												});
							});
			$(document)
					.ready(
							function() {
								$('#ShopProfile')
										.dataTable(
												{
													"sPaginationType" : "bs_four_button",
													"oLanguage" : {
														"sSearch" : "",
														"sZeroRecords" : "Không có dữ liệu",
														"sEmptyTable" : "Không có dữ liệu",
														"sInfo" : "Hiển thị từ _START_ đến _END_. Tổng cộng: _TOTAL_ dòng.",
														"sInfoFiltered" : "",
														"sLengthMenu" : "Hiển thị _MENU_ Dòng",
														"sInfoEmpty" : 'Không tìm thấy dữ liệu.'
													},
												});
								$('#ShopProfile')
										.each(
												function() {
													var datatable = $(this);
													// SEARCH - Add the placeholder for Search and Turn this into in-line form control
													var search_input = datatable
															.closest(
																	'.dataTables_wrapper')
															.find(
																	'div[id$=_filter] input');
													search_input.attr(
															'placeholder',
															'Tìm Kiếm');
													search_input
															.addClass('form-control input-sm');
													// LENGTH - Inline-Form control
													var length_sel = datatable
															.closest(
																	'.dataTables_wrapper')
															.find(
																	'div[id$=_length] select');
													length_sel
															.addClass('form-control input-sm');
												});
							});
			$(document)
					.ready(
							function() {
								$('#BannedProfile')
										.dataTable(
												{
													"sPaginationType" : "bs_full",
													"oLanguage" : {
														"sSearch" : "",
														"sZeroRecords" : "Không có dữ liệu",
														"sEmptyTable" : "Không có dữ liệu",
														"sInfo" : "Hiển thị từ _START_ đến _END_. Tổng cộng: _TOTAL_ dòng.",
														"sInfoFiltered" : "",
														"sLengthMenu" : "Hiển thị _MENU_ Dòng",
														"sInfoEmpty" : 'Không tìm thấy dữ liệu.'
													}
												});
								$('#BannedProfile')
										.each(
												function() {
													var datatable = $(this);
													// SEARCH - Add the placeholder for Search and Turn this into in-line form control
													var search_input = datatable
															.closest(
																	'.dataTables_wrapper')
															.find(
																	'div[id$=_filter] input');
													search_input.attr(
															'placeholder',
															'Search');
													search_input
															.addClass('form-control input-sm');
													// LENGTH - Inline-Form control
													var length_sel = datatable
															.closest(
																	'.dataTables_wrapper')
															.find(
																	'div[id$=_length] select');
													length_sel
															.addClass('form-control input-sm');
												});
							});
		</script>

		<script type="text/javascript" src="js/jquery.dataTables.js"></script>
		<script type="text/javascript" src="js/datatables.js"></script>
	</tiles:put>
</tiles:insert>
</html:html>
